package com.example.ross.controller;

import com.example.ross.common.Result;
import com.example.ross.entity.SysUser;
import com.example.ross.form.UserForm;
import com.example.ross.service.LoginService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @version 1.0.0
 * @className: LoginController
 * @description:
 * @author: zhangjunfa
 * @date: 2023/5/6 18:21
 */
@Slf4j
@Api(tags = "登录")
@RestController
@RequestMapping
public class LoginController {
    @Autowired
    private LoginService loginService;

    @PostMapping("/login")
    public Result<?> login(UserForm user) {
        Map<String, String> token = loginService.login(user);
        log.info("Token jwt:{}", token.get("token"));
        return Result.success(token);
    }
}
